package com.jsnj33.pdaproject.utils;

import android.app.Dialog;
import android.content.Context;
import android.widget.TextView;

import com.jsnj33.pdaproject.R;

/**
 * 作者：LGP on 2017/12/28 13:39
 * 邮箱：1712115388@qq.com
 */
public class LoadingUtils {
    private static Dialog dialog;
    private static TextView tvMsg;

    public static Dialog getDialogInstance(Context context){
        dialog = new Dialog(context, R.style.progress_dialog);
        dialog.setContentView(R.layout.dialog);
        dialog.setCancelable(true);
        dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        tvMsg = (TextView) dialog.findViewById(R.id.id_tv_loadingmsg);
        return dialog;
    }

    public static void setMessage(String msg){
        tvMsg.setText(msg);
    }

    public static void show(){
        if(!dialog.isShowing()){
            dialog.show();
        }
    }

    public static void dismiss(){
        if(dialog.isShowing()){
            dialog.dismiss();
        }
    }

    public static void setCancelable(boolean cancelable){
        dialog.setCancelable(cancelable);
    }

}
